package com.acme.bankapp.domain;

public class Client {
	private Gender gender;
	private String name;
	
	private Account[] accounts;
	int numberOfAccounts;
	
	public int getNumberOfAccounts() {
		return numberOfAccounts;
	}
	public Client(String name, Gender gender) {
		this.name = name;
		this.gender = gender;
		accounts = new Account[10];
	}
	public Client() {
		this("",Gender.MALE);
	}
	
	public String getClientSituation() {
		return gender.getStr() + name;
	}
	
	public void addAccount(Account account) {
		accounts[numberOfAccounts++] = account;
	}

	public Account[] getAccounts() {
		return accounts;
	}
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + numberOfAccounts;
		return result;
	}
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	public String toString() {
		StringBuffer SB = new StringBuffer().append(gender.getStr()+name).append("Accounts: \n");
		for (int i = 0; i < numberOfAccounts; i++) {
			SB.append(accounts[i]+"\n");
		}
		return SB.toString();
	}
	
	
}

